/**
 * Copyright (c) 2016-present, ecidi.
 * All rights reserved.
 * 
 * This source code is licensed under the GPL-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

import React from 'react';
import ReactDOM from 'react-dom';
//antdesign3.0国际化概念
import { LocaleProvider } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
//antdesign3.0需要引入moment
import 'moment/locale/zh-cn';
import 'babel-polyfill';
require('es6-promise').polyfill();

const MOUNT_NODE = document.getElementById('root');

let render = () => {
	const NextApp = require('./Page').default
	ReactDOM.render(<LocaleProvider locale={zhCN}><NextApp /></LocaleProvider>, MOUNT_NODE);
}
if (__DEV__) {
	const renderApp = render;
	const renderError = (error) => {
		const RedBox = require('redbox-react').default;
		ReactDOM.render(<RedBox error={error}/>, MOUNT_NODE);
	};
	render = () => {
		try {
			renderApp();
		} catch (error) {
			renderError(error);
		}
	};
}

if (module.hot) {
	module.hot.accept('./Page', () => 
		setImmediate(() => {
			ReactDOM.unmountComponentAtNode(MOUNT_NODE);
			render();
		})
	);
}
render();

